package cn.appsys.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import cn.appsys.controller.backend.BackendLoginController;
import cn.appsys.controller.developer.DevLoginController;
import cn.appsys.pojo.BackendUser;
import cn.appsys.pojo.DevUser;




public class SysInterceptor extends HandlerInterceptorAdapter{
   @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
		throws Exception {
	System.out.println("拦截器。。。。");
	DevUser loginUser = (DevUser) request.getSession().getAttribute(DevLoginController.DEV_USER_SESSION);
	BackendUser backendUser = (BackendUser)request.getSession().getAttribute(BackendLoginController.USER_SESSION);
	/*if (loginUser == null) {// 说明没登录, 就打回去, 不能让你往下
		response.sendRedirect(request.getContextPath()+"/403.jsp");
		return false;
	}else if (backendUser==null) {
		response.sendRedirect(request.getContextPath()+"/403.jsp");
		return false;
	}
	return true;// 放行
*/if(null != loginUser){ //dev SUCCESS
	return true;
}else if(null != backendUser){ //backend SUCCESS
	return true;
}else{
	response.sendRedirect(request.getContextPath()+"/403.jsp");
	return false;
}
	}
}
